package view;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;

public class ReadOrManagerFrame extends JFrame {
    public ReadOrManagerFrame() throws HeadlessException {
        this.setTitle("爬取/管理数据");

        this.setBounds(400,300,600,250);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        FlowLayout flowLayout = new FlowLayout(FlowLayout.CENTER);
        this.setLayout(flowLayout);
        //需要添加两个按钮
        JButton jButtonRead = new JButton("爬取数据");
        JButton jButtonMnager = new JButton("管理数据");
        Dimension dimension = new Dimension(200,200);
        Font font = new Font("楷体",Font.BOLD,30);
        jButtonRead.setPreferredSize(dimension);
        jButtonMnager.setPreferredSize(dimension);
        jButtonRead.setFont(font);
        jButtonMnager.setFont(font);
        this.add(jButtonRead);
        this.add(jButtonMnager);

        jButtonRead.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new ReadJobFrame().setVisible(true);
            }
        });

        jButtonMnager.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    new ManagerJobFrame().setVisible(true);
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                } catch (ClassNotFoundException classNotFoundException) {
                    classNotFoundException.printStackTrace();
                }
            }
        });

    }

    @Override
    public void setVisible(boolean b) {
        super.setVisible(b);
    }
}
